//
//  StoreInformationOneTableViewCell.m
//  GLGW_Shoping
//
//  Created by whx on 2018/12/10.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "StoreInformationOneTableViewCell.h"

@implementation StoreInformationOneTableViewCell
{
    GLGWLabel *leftLab;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        GLGWView *view = [[GLGWView alloc] initWithInSuperView:self.contentView];
        view.backgroundColor = [UIColor colorWithHexString:@"#F2F2F2"];
        [view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.right.equalTo(self.contentView);
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(10)));
        }];
        
        GLGWLabel *lab = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(16) theColor:kColor_Rule_Black inSuperView:self.contentView];
        lab.text = @"请设置一个店铺名称";
        [lab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@(kWidthProportion_In_iPhoneTriploid(15)));
            make.top.equalTo(view.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(20));
            make.bottom.equalTo(@(-kHeightProportion_In_iPhoneTriploid(22)));
        }];
        leftLab = lab;
        
        UITextField *textF = [[UITextField alloc] init];
        textF.font = SYSTEMFONT(16);
        textF.textColor = kColor_Rule_Black;
        [self.contentView addSubview:textF];
        [textF mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@(kWidthProportion_In_iPhoneTriploid(15)));
            make.top.equalTo(view.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(20));
            make.bottom.equalTo(@(-kHeightProportion_In_iPhoneTriploid(22)));
            make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(40));
        }];
        textF.hidden = YES;
        textF.placeholder = @"请输入关键字（15字以内）";
        self.textF = textF;
        
        GLGWButton *btn = [[GLGWButton alloc] initInSuperView:self.contentView];
        [btn setImage:[UIImage imageNamed:@"icon_dizhiguanli_genggai"] forState:UIControlStateNormal];
        [btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView.mas_right);
            make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(48)));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(30)));
            make.centerY.equalTo(lab.mas_centerY);
        }];
        [btn addTarget:self action:@selector(btnAction:) forControlEvents:UIControlEventTouchUpInside];
    }
    return self;
}

- (void)btnAction:(GLGWButton *)sender
{
    leftLab.hidden = YES;
    _textF.hidden = NO;
    sender.hidden = YES;
    [_textF becomeFirstResponder];
//    if (self.BlockAction) {
//        self.BlockAction(sender);
//    }
}

- (void)setLeftStr:(NSString *)leftStr
{
    _leftStr = leftStr;
    leftLab.text = leftStr;
}

@end
